package com.tanhua.dubbo.api.mapper;




import com.tanhua.model.db.QuestionAndoptionsScore;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface QuestionAndoptionsScoreMapper {

    @Select("<script>"+
            "select sum(q.score) as questionscore,sum(o.fraction) as optionscore,q.sum from tb_questions q,tb_options o" +
            "<foreach collection=\"questionId\" item=\"item\" open=\"where q.id in(\" close=\")\" separator=\",\">\n" +
            "            #{item}" +
            "</foreach>"+
            "<foreach collection=\"optionId\" item=\"item\" open=\"and o.id in(\" close=\")\" separator=\",\">\n" +
            "            #{item}" +
            "        </foreach>" +
            "AND o.`questions_id` = q.`id`" +
            "group by q.sum"+
            "</script>")
    List<QuestionAndoptionsScore> sumScore(@Param(value = "questionId") List<Integer> questionId, @Param(value="optionId") List<Integer> optionId);

}
